﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace qtAiGamesLibrary
{
    /// <summary>
    /// The base class for all objects in the game. This allows for easy messaging between objects
    /// as well as easy positioning etc
    /// The Default implementation is 2D.
    /// </summary>
    public class BaseGameEntity
    {
        public enum tEntityType
        {
            Default = -1
        }
        
        private int _ID;                // Each object needs to have an ID, makes it easy to find
        private int _EntityType;        // Type to differentiate what it is.
        private bool _bTag;             // a Generic flag
        private object _objTag;         // a generic pointer to any object. Use sparingly

        #region *- PROPERTIES -*

        public int ID { get { return _ID; } }
        public int EntityType { get { return _EntityType; } set { _EntityType = value; } }
        public bool bTag { get { return _bTag; } set { _bTag = value; } }
        public object objTag { get { return _objTag; } set { _objTag = value; } }

        public Vector2 vPos { get { return _vPos; } set { _vPos = value; } }
        public Vector2 vScale { get { return _vScale; } set { _vScale = value; } }

        #endregion

        // Private functions
        // used by the constructor to give each entity a unique ID
        private int NextValidID(){ return _NextValidID++; } 
        
        // Statics:
        private static int _NextValidID = 0;


        /// Protected
        

        // Constructors are protected ;)
        protected BaseGameEntity()
        {
            _ID = NextValidID();
            _dBoundingRadius = 0.0f;
            _vPos = Vector2.Zero;
            _vScale = Vector2.One;
            _EntityType = (int)tEntityType.Default;
            _bTag = false;
            _objTag = null;
        }
    


        protected Vector2 _vPos;            // Position in the world
        protected Vector2 _vScale;          // Scale size
        protected float _dBoundingRadius;  // Bounding radius for collision and avoidance!


        /// Public
        public void SetScale(Vector2 value) { _dBoundingRadius *= Math.Max(value.X, value.Y)/Math.Max(_vScale.X, _vScale.Y); _vScale = value; }
        public void SetScale(float value) { _dBoundingRadius *= (value/Math.Max(_vScale.X, _vScale.Y)); _vScale = new Vector2(value, value); }



    }
}
